<!--职位管理页-->
<template>
  <!-- 职位管理搜索卡片 -->
  <el-card style="margin:20px;height: 70px;">
    <el-form :inline="true">
      <el-form-item label="职位名称">
        <el-input placeholder="请输入内容" style="width:220px;" v-model="searchPositionForm.positionName"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="resetSearch">重置</el-button>
        <el-button type="primary" @click="loadPosition">查询</el-button>
      </el-form-item>
      <el-form-item style="padding-left: 800px;">
        <el-button type="primary" @click="beforeAddPos">新增职位</el-button>
      </el-form-item>
    </el-form>
  </el-card>
  <!--  新增职位弹窗-->
  <el-dialog v-model="dialogVisible" :title="dialogTitle">
    <el-form label-width="80px">

      <el-form-item label="职位名称">
        <el-input placeholder="请输入内容" v-model="savePositionForm.positionName"></el-input>
      </el-form-item>
      <el-form-item label="组织名称">
        <el-select placeholder="请选择" v-model="savePositionForm.orgName">
          <el-option label="组织架构1" value="1"></el-option>
          <el-option label="组织架构2" value="2"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="职级">
        <el-select placeholder="请选择" v-model="savePositionForm.levelName">
          <el-option label="组织架构1" value="1"></el-option>
          <el-option label="组织架构2" value="2"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="职位描述">
        <el-input type="textarea" placeholder="请输入内容" v-model="savePositionForm.description"></el-input>
      </el-form-item>
    </el-form>
    <template #footer>
      <el-button @click="handleClose">取 消</el-button>
      <el-button type="primary" @click="savePosition">确 定</el-button>
    </template>
  </el-dialog>
  <!-- 职位管理列表 -->
  <el-card style="margin:20px;">
    <el-table :data="PositionArr">
      <el-table-column type="selection" width="80"></el-table-column>
      <el-table-column type="index" label="编号" width="80" align="center"/>
      <el-table-column prop="brand" label="职位名称" align="center">
      </el-table-column>
      <el-table-column prop="license" label="组织部门" align="center"/>
      <el-table-column prop="type" label="职级" align="center"/>
      <el-table-column label="操作" align="center">
        <template #default="scope">
          <el-button link type="primary" size="small" @click="editPosition(scope.row.id)">编辑</el-button>
          <el-button link type="primary" size="small" @click="deletePosition(scope.row.id)">删除</el-button>

        </template>
      </el-table-column>


    </el-table>
  </el-card>
</template>
<script setup>

import {onMounted, ref} from "vue";

const dialogVisible = ref(false);
//定义变量控制dialog的标题
const dialogTitle = ref('新增职位');
const beforeAddPos = () => {
  dialogVisible.value = true;
  dialogTitle.value = '新增职位';
  console.log(dialogTitle.value);
}
//定义对象用来收集搜索卡片表单的数据
const searchPositionForm = ref({
  positionName: '',//职位名称
});
//定义搜索卡片重置按钮的功能 清空值+重新加载车辆
const resetSearch = ()=>{
  searchPositionForm.value = {};
  loadPosition();
}

//定义对象用来收集弹窗表单的数据
const savePositionForm = ref({
  positionName: '',//职位名称
  orgName: '',//组织名称
  levelName: '',//职级名称
  description: '',//职位描述
});

//定义加载职位管理的方法
const loadPosition = ()=>{

}
//定义数组用来保存组织表格数据
const PositionArr = ref([]);
//定义保存职位管理
const savePosition = ()=>{

}
//处理保存职位管理弹窗关闭的方法
const handleClose = ()=>{
  if(confirm('您确认要关闭本弹窗吗?')){
    dialogVisible.value = false;
  }
}
//定义编辑职位管理的方法
const editPosition = (id)=>{

}
//定义删除指定职位管理的方法
const deletePosition = (id)=>{

}
//onMounted() VUE的生命周期钩子 在DOM渲染完毕后立即执行
onMounted(()=>{
  loadPosition();
})

</script>